package com.inet.test05;


import java.io.*;
import java.net.Socket;

/**
 * @Author weijingchen
 * @Date 2025/6/26 15:15
 * @Version 1.0.0
 */
public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 10301);

        //读取本地文件
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("src/main/resources/b.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
        int len;
        byte[] bytes = new byte[1024];
        while ((len = bis.read(bytes)) != -1) {
            bos.write(bytes, 0, len);
            System.out.println(new String(bytes, 0, len));
            bos.flush();
        }
        socket.shutdownOutput();
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String s = br.readLine();
        System.out.println(s);
        socket.close();

    }
}
